package Book;
//对书类进行抽象
public class book {
    private String name;
    private String auther;
    private double price;
    private String bookStyle;
    private boolean isBorrowed;

    /**
     * 书类的一个带参数的构造方法(不含成员属性isBorrowed)
     * 因为isBorrowed是一个布尔类型的成员属性，就算构造方法未对其进行传参
     * 初始化，在类中也会默认初始化为false,又因为在添加一个书时，默认的借出状态
     * 也为未借出(false),正因为布尔类型属性这一特点，所以构造方法中不用对其传参
     * 初始化
     * @param name 书名
     * @param auther 作者
     * @param price 价格
     * @param bookStyle 类型
     */
    public book(String name, String auther, double price, String bookStyle) {
        this.name = name;
        this.auther = auther;
        this.price = price;
        this.bookStyle = bookStyle;
    }

    /**
     * 对ToString方法进行重写，方便对书类对象的属性信息打印
     * @return
     */
    @Override
    public String toString() {
        return "book{" +
                "name='" + name + '\'' +
                ", auther='" + auther + '\'' +
                ", price=" + price +
                ", bookStyle='" + bookStyle + '\'' +
                ", isBorrowed=" + (isBorrowed?"已借出":"未借出") +
                '}';
    }

    /**
     *返回当前书对象的书名(name)
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     * 设置当前书对象的书名(name)
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 返回当前书对象的作者名字(auther)
     * @return
     */
    public String getAuther() {
        return auther;
    }

    /**
     * 设置当前书对象的作者名字(auther)
     * @param auther
     */
    public void setAuther(String auther) {
        this.auther = auther;
    }

    /**
     * 返回当前书对象的价格(price)
     * @return
     */
    public double getPrice() {
        return price;
    }

    /**
     * 设置当前书对象的价格(price)
     * @param price
     */
    public void setPrice(double price) {
        this.price = price;
    }

    /**
     * 返回当前书对象的类型(bookStyle)
     * @return
     */
    public String getBookStyle() {
        return bookStyle;
    }

    /**
     * 设置当前书对象的类型(bookStyle)
     * @param bookStyle
     */
    public void setBookStyle(String bookStyle) {
        this.bookStyle = bookStyle;
    }

    /**
     * 返回当前对象的借阅状态(isBorrowed)
     * @return
     */
    public boolean getIsBorrowed() {
        return isBorrowed;
    }

    /**
     * 设置当前对象的借阅状态(isBorrowed)
     * @param borrowed true或false
     */
    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }
}


